1. Field of the Invention
The present invention relates to a storage device characterized by a method of managing a data buffer. More particularly, this invention is concerned with a storage device in the form of an optical disk drive in a host computer and in which a data buffer is efficiently managed using an operating system (hereinafter OS).
2. Description of the Related Art
Conventionally, a file system employing an optical disk drive has a problem in that since the reading/writing rate permitted by the optical disk drive is lower than the processing speed permitted by a host computer (for example, the operating frequency of the host computer is 200 MHz and the operating frequency of the optical disk drive is about 25 MHz). If the data transfer rate is synchronized with the data reading/writing rate, the processing ability of the host computer deteriorates.
When the optical disk drive is connected to the host computer for use, a data buffer, with a high data transfer rate and referred to as a cache memory, is incorporated in the optical disk drive. Among instructions and data items sent from the host computer, those exhibiting high possibilities of future use are temporarily stored in the cache memory. Thus, the processing ability of the host computer is improved. The cache memory receives all the data items immediately and reports Normal Termination. When Normal Termination is reported, the OS of the host computer activates another task. This results in efficient processing. The control thus provided so that data temporarily stored in the cache memory can be used later is referred to as cache control. It is firmware in the optical disk drive, that is, a program residing in a ROM inside an MPU, that is responsible for cache control.
The cache control will be explained in more detail. For example, for writing data in the optical disk drive, the data is temporarily written in the cache memory in the optical disk drive, and the data in the cache memory is written slowly to an optical disk. By contrast, for reading data from the optical disk drive, data read from the optical disk is written in the cache memory and then transferred.
However, when data is initially read from the optical disk drive, since no data is present in the cache memory, the data transfer rate becomes equal to the reading rate permitted by the optical disk drive. When one file is read in response to a request sent from the OS, one sector is read with the first command. Since the possibility that reading the next sector (data written immediately successively) will be indicated by the next command sent from the OS is high, after the optical disk drive receives one command and returns Normal Termination to the OS, it starts reading data from the next sector before the next command comes, and stores the data in the cache memory. If the data stored in the cache memory matches data requested by the next command (if a cache hit is made), the stored data can be transferred from the cache memory.
However, when a requested sector indicated by the next command is different from a sector whose data has been stored in the cache memory (data in the sector does not make a cache hit), data in the indicated sector of the optical disk drive is read again by using processing time. This is inefficient. It is therefore demanded to improve a hit ratio, relative to data stored in advance in the cache memory, when data is read from the optical disk drive.
Information handled by a computer is programs and data items. For facilitating classifying of or working on the programs and data items, such as, storage, reading, retrieval, and correction, the programs and data items are each named in units of a certain set of information blocks (this is called a file). The OS of a host computer manages data items in memory areas included in all storage devices by adopting a unique control mode. Whichever of various control modes is adopted, at least the three facilities to be described below are included for managing data.
(1) File allocation table (hereinafter FAT)
(2) Directory (hereinafter DIR)
(3) Data division
The FAT is used to store the one or more addresses of the subsequent sectors of the file which is stored over a plurality of sectors of a disk medium to be loaded in an optical disk drive. The DIR is used to store a leading address and file name of each file. The data division is used to store data.
For reading file data, the OS first reads information concerning the data division from the FAT and DIR. Based on the read information, the OS reads data from the data division. In other words, for reading data from the data division, the work of reading the FAT and DIR must be carried out without fail.
However, a conventional cache control mode does not care about a procedure of reading the FAT, DIR, and data division in a cache memory. According to a reading instruction sent from the OS, the FAT, DIR, and data division of a disk medium are read at random, and read data is stored in the cache memory. Furthermore, data succeeding the data read with a previous instruction is read ahead and stored in the cache memory until the next instruction comes. If the data division consists of distributed spaces, there is a problem that the probability that data items corresponding to data items in the FAT and DIR will be found in the cache memory is low.
The problem will be described more particularly. According to a prior art, a cache memory is not divided into areas in which data items to be read from a FAT, DIR, and data division are stored. When a Read command indicating reading of the FAT comes first, data is read from the first sector within the FAT. Thereafter, data is read from the next and subsequent sectors within the FAT, and then stored in the cache memory. If the next Read command indicates reading of the data division but not of the FAT, the data read ahead from the FAT is overwritten with data read from a sector within the data division. Thereafter, data is read from the next sector within the data division and stored. The data read ahead from the FAT is demolished. Even if a Read command indicating reading of the FAT comes thereafter, the data read from the FAT has already disappeared from the cache memory. Data in the FAT does not make a hit. The same applies to data in the DIR or data division.